package com.gdiss.www.controller;

import com.gdiss.www.bo.UserLoginBo;
import com.gdiss.www.service.UserService;
import com.gdiss.www.vo.ResultVo;
import com.gdiss.www.vo.request.RegisterVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author Velore
 * @date 2022/1/20
 **/
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("test1")
    public String test1() {
        return "this is a get test from userController";
    }

    @PostMapping("test2")
    public String test2() {
        return "this is a post test from userController";
    }

    @PostMapping("login")
    public ResultVo<String> login(@RequestBody UserLoginBo userLoginBo) {
        String token = userService.login(userLoginBo);
        return new ResultVo(token);
    }

    @PostMapping("register")
    public ResultVo<String> register(@RequestBody RegisterVo registerVo){
        userService.register(registerVo);
        return new ResultVo<>("success");
    }


}
